#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,s[20000],pos[20000]; 
int main(){
	ios::sync_with_stdio(0);
  	freopen("rotate.in","r",stdin);
  	freopen("rotate.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i],pos[s[i]]=i;
	vector<int> v;
	int len=3;
	cout<<len<<' ';
	for(int i=1;i<=n-len;i++){
		while(pos[i]>n-len+1){
			for(int k=n-len+2;k<=n;k++)swap(s[k],s[k-1]),swap(pos[s[k]],pos[s[k-1]]);
			v.push_back(n-len+1);
		}
		for(int j=pos[i];j>1;j--){
			if(s[j]<s[j-1]){
				for(int k=j;k<j+len-1;k++)swap(s[k],s[k-1]),swap(pos[s[k]],pos[s[k-1]]);
				v.push_back(j-1);
			}else break;
		}
		if(/*!is_sorted(s+1,s+1+i)*/s[i]!=i){
			cerr<<"tlhll:"<<i<<'\n';
			bool ok=1;
			for(int i=1;i<=n;i++)ok&=pos[s[i]]==i;
			cerr<<ok<<' '<<pos[i]<<' '<<s[i]<<'\n';
			for(int i=1;i<=n;i++)cerr<<s[i]<<' ';
			exit(0);
		}
	}
	int cnt=0;
	cerr<<v.size()<<'\n';
	while(!is_sorted(s+1,s+1+n)){
		for(int k=n-len+2;k<=n;k++)swap(s[k],s[k-1]);
		v.push_back(n-len+1);
		cerr<<"gg\n";
		cnt++;
		if(cnt>=len){
			for(int i=n-len+1;i<=n;i++)cerr<<s[i]<<' ';
			return 1;
		}
	}
	cout<<v.size()<<'\n';
	for(int i:v)cout<<1<<' '<<i<<'\n';
}
